package StreamDemo.demo2;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collector;
import java.util.stream.Collectors;

public class test2 {
    public static void main(String[] args){
        // 创建集合
        ArrayList<String> list = new ArrayList<>();
        Collections.addAll(list,"zhangsan,23","lisi,24","wangwu,25");
        Map<String,Integer> hm = list.stream()
        .filter(s -> Integer.parseInt(s.split(",")[1]) >= 24)
        .collect(Collectors.toMap(new Function<String,String>() {
            @Override
            public String apply(String s){
                return s.split(",")[0];
            }
        },new Function<String,Integer>() {
            @Override
            public Integer apply(String s){
                return Integer.parseInt(s.split(",")[1]);
            }
        }));
        Map<String,Integer> hm1 = list.stream()
        .filter(s -> Integer.parseInt(s.split(",")[1]) >= 24)
        .collect(Collectors.toMap(s -> s.split(",")[0],s -> Integer.parseInt(s.split(",")[1])));
        System.out.println(hm);
        System.out.println(hm1);
        
    }
}
